* Effects of mass shootings in nearby states

set more off

eststo clear
loc m = 1

// main regressions  {{{

foreach iv in shoot fatal {
    // neighboring states
    xtpoisson `dv' L.``iv'' L.`adj`iv'' `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo m`m', title("`dv' adj `iv'")
    loc m = `m' + 1

    // census division
    xtpoisson `dv' L.``iv'' L.cendiv_`iv' `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo m`m', title("`dv' div `iv'")
    loc m = `m' + 1

    // census region
    xtpoisson `dv' L.``iv'' L.cenreg_`iv' `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo m`m', title("`dv' reg `iv'")
    loc m = `m' + 1
}

// }}}


// political interactions
// ----------------------------------------------------------------------------

// independent variables  {{{
loc svars "shootXrepleg shootXdemleg shootXsplleg"
loc fvars "fatalXrepleg fatalXdemleg fatalXsplleg"

loc adj_svars "`svars' adjshootXrepleg adjshootXdemleg adjshootXsplleg"
loc adj_fvars "`fvars' adjfatalXrepleg adjfatalXdemleg adjfatalXsplleg"

loc div_svars "`svars' cendiv_shootXrepleg cendiv_shootXdemleg cendiv_shootXsplleg"
loc div_fvars "`fvars' cendiv_fatalXrepleg cendiv_fatalXdemleg cendiv_fatalXsplleg"

loc reg_svars "`svars' cenreg_shootXrepleg cenreg_shootXdemleg cenreg_shootXsplleg"
loc reg_fvars "`fvars' cenreg_fatalXrepleg cenreg_fatalXdemleg cenreg_fatalXsplleg"
// }}}

// regressions  {{{

foreach iv in s f {

    // neighboring states
    xtpoisson `dv' `adj_`iv'vars' `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo m`m', title("`dv' `iv'adj")
    loc m = `m' + 1

    // census division
    xtpoisson `dv' `div_`iv'vars' `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo m`m', title("`dv' `iv'div")
    loc m = `m' + 1

    // census region
    xtpoisson `dv' `reg_`iv'vars' `controls' `rng', `opt'
    qui estadd local sfix = "Yes"
    if regexm("`controls'", "i\.year") qui estadd local yfix "Yes"
    eststo m`m', title("`dv' `iv'reg")
    loc m = `m' + 1
}
// }}}



writemodel using "`out'/neighbor_`dv'", drop(*.year) ext(csv)       /*
    */ order(L.`shoot' L.`adjshoot' L.cendiv_shoot L.cenreg_shoot   /*
    */       L.`fatal' L.`adjfatal' L.cendiv_fatal L.cenreg_fatal   /*
    */       `svars' `adj_svars' `div_svars' `reg_svars'            /*
    */       `fvars' `adj_fvars' `div_fvars' `reg_fvars')

exit
// vim: foldmethod=marker
